//
//  XKMineFunctionCell.m
//  XKJY
//
//  Created by xuyaguang on 2017/1/12.
//  Copyright © 2017年 xiaokang100. All rights reserved.
//

#import "XKMineFunctionCell.h"


@interface XKMineFunctionCell ()
@property (nonatomic, strong) UIImageView *iconImageView;
@property (nonatomic, strong) UIImageView *arrowImageView;
@property (nonatomic, strong) UILabel     *titleLabel;
@property (nonatomic, strong) UILabel     *remindLabel;
@property (nonatomic, strong) UILabel     *lineView;
@end
@implementation XKMineFunctionCell

#pragma mark - 自定义cell重写构造方法
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createSubviews];
        [self addConstraints];
    }
    return self;
}


#pragma mark - 创建控件
- (void)createSubviews {
    _iconImageView = [UIImageView new];
    
    _arrowImageView = [UIImageView new];
    _arrowImageView.image = [UIImage imageNamed:@"my_con_icon_next"];
    
    _titleLabel = [UILabel getLabWithText:@"--"
                                 textFont:Font_15
                                textColor:BlackColor];
    
    _remindLabel = [UILabel getLabWithText:@"未认证"
                                  textFont:Font_15
                                 textColor:RedColor
                             textAlignment:NSTextAlignmentRight];
    _remindLabel.alpha = 0;
    
    _lineView = [UILabel new];
    _lineView.backgroundColor = kBaseGrayColor;
    
}
#pragma mark - 添加约束
- (void)addConstraints {
    
    
    [self.contentView addSubview:self.iconImageView];
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20*Scale_W);
        make.top.mas_equalTo(10*Scale_H);
        make.size.mas_equalTo(CGSizeMake(30*Scale_W, 30*Scale_W));
        make.bottom.mas_equalTo(self.contentView).offset(-10*Scale_H).priorityHigh();
    }];
    
    
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.iconImageView.mas_right).offset(10*Scale_W);
        make.right.mas_equalTo(self.contentView).offset(-100*Scale_W);
        make.centerY.mas_equalTo(self.iconImageView);
    }];
    
    
    [self.contentView addSubview:self.remindLabel];
    [self.remindLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.contentView).offset(-40*Scale_W);
        make.centerY.mas_equalTo(self.iconImageView);
    }];
    
    
    [self.contentView addSubview:self.arrowImageView];
    [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.contentView).offset(-20*Scale_W);
        make.centerY.mas_equalTo(self.iconImageView);
        make.size.mas_equalTo(CGSizeMake(8*Scale_W, 14*Scale_W));
    }];
    
    [self.contentView addSubview:self.lineView];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.mas_equalTo(self.contentView);
        make.height.mas_equalTo(1*Scale_H);
    }];
}


- (void)setIconImgName:(NSString *)iconImgName {
    _iconImgName = iconImgName;
    _iconImageView.image = [UIImage imageNamed:iconImgName];
}

- (void)setTitleString:(NSString *)titleString {
    _titleString = titleString;
    _titleLabel.text = titleString;
}

- (void)setCertifiedState:(CertifiedState)certifiedState {
    _certifiedState = certifiedState;
    
    _remindLabel.alpha = 1;
    if (certifiedState == 0) {
        self.remindLabel.text = @"未认证";
        self.remindLabel.textColor = RedColor;
    } else if (certifiedState == 1) {
        self.remindLabel.text = @"已认证";
        self.remindLabel.textColor = RGB(27, 180, 72);
    } else if (certifiedState == 2) {
        self.remindLabel.text = @"认证中...";
        self.remindLabel.textColor = GrayColor;
    } else {
        self.remindLabel.alpha = 0;
    }
}
@end
